#include "VentiladorCamila.h"
#include <GL/glu.h>
#include <GL/gl.h>
#include "gllib/Objects.h"
#include <math.h>

void VentiladorCamila::draw() {
    //base
    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    gllibCone(0.3, 0.2, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.0, -0.2, 0.0);
    //glRotatef(90, 1.0, 0.0, 0.0);
    glScalef(1.0, 0.1, 1.0);
    gllibCube(1.0);
    glPopMatrix();

    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.0, -0.2, 0.5);
    glRotatef(90, 0.0, 0.0, 1.0);
    //glScalef(1.0, 0.1, 1.0);
    gllibCylinder(0.05, 1.0, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.0, -0.2, -0.5);
    glRotatef(90, 0.0, 0.0, 1.0);
    //glScalef(1.0, 0.1, 1.0);
    gllibCylinder(0.05, 1.0, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.5, -0.2, 0.0);
    glRotatef(90, 1.0, 0.0, 0.0);
    gllibCylinder(0.05, 1.0, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(-0.5, -0.2, 0.0);
    glRotatef(90, 1.0, 0.0, 0.0);
    gllibCylinder(0.05, 1.0, 20);
    glPopMatrix();


    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.0, 0.55, 0.0);
    gllibCylinder(0.1, 1.2, 20);
    glPopMatrix();


    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.0, 1.3, 0.0);
    glRotatef(90, 1.0, 0.0, 0.0);
    gllibCylinder(0.2, 0.4, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0.5,0.5,1.0);
    glTranslatef(0.0, 1.3, 0.4);
    glRotatef(90, 1.0, 0.0, 0.0);
    gllibCylinder(0.1, 0.1, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0.8,0.8,0.8);
    glTranslatef(0.0, 1.3, 0.2);
    glRotatef(90, 1.0, 0.0, 0.0);
    gllibCylinder(0.02, 0.3, 20);
    glPopMatrix();

    //centro
    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.0, 1.3, 0.58);
    glRotatef(90, 1.0, 0.0, 0.0);
    gllibCylinder(0.14, 0.05, 20);
    glPopMatrix();

//grades: frente e costa
    for(double teta = -180; teta < 180; teta += 10){
        glPushMatrix();
        glColor3f(1.0,1.0,1.0);
        glTranslatef(0.0, 1.3, 0.4);
        glRotatef(teta, 0.0, 0.0, 1.0);
        glScalef(0.5, 0.5, 0.5);
        grade();
        glPopMatrix();
    }

    for(double teta = -180; teta < 180; teta += 10){
        glPushMatrix();
        glColor3f(1.0,1.0,1.0);
        glTranslatef(0.0, 1.3, 0.4);
        glRotatef(teta, 0.0, 0.0, 1.0);
        glRotatef(180, 1.0, 0.0, 0.0);
        glScalef(0.5, 0.5, 0.5);
        grade();
        glPopMatrix();
    }

    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.0, 1.3, 0.4);
    glRotatef(90, 1.0, 0.0, 0.0);
    glScalef(1.0, 0.4, 1.0);
    gllibTorus(0.02, 0.725, 20, 20);
    glPopMatrix();

    //pa
    glPushMatrix();
    glTranslatef(-0.25, 1.6, 0.45);
    glRotatef(-45, 0.0, 0.0, 1.0);
    glScalef(0.6, 0.6, 0.6);
    pa();
    glPopMatrix();

    glPushMatrix();
    glTranslatef(0.25, 1.4, 0.45);
    glRotatef(-165, 0.0, 0.0, 1.0);
    glScalef(0.6, 0.6, 0.6);
    pa();
    glPopMatrix();

    glPushMatrix();
    glTranslatef(-0.13, 1.05, 0.45);
    glRotatef(-285, 0.0, 0.0, 1.0);
    glScalef(0.6, 0.6, 0.6);
    pa();
    glPopMatrix();

    //botoes
    glPushMatrix();
    glColor3f(0.0,0.0,0.9);
    glTranslatef(-0.075, -0.125, 0.40);
    gllibCylinder(0.05, 0.02, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0.0,0.0,0.9);
    glTranslatef(0.075, -0.125, 0.40);
    gllibCylinder(0.05, 0.02, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0.0,0.0,0.9);
    glTranslatef(-0.225, -0.125, 0.40);
    gllibCylinder(0.05, 0.02, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0.0,0.0,0.9);
    glTranslatef(0.225, -0.125, 0.40);
    gllibCylinder(0.05, 0.02, 20);
    glPopMatrix();

}

void VentiladorCamila::pa(){
    glPushMatrix();
    glColor3f(0.5,0.5,1.0);
    glTranslatef(0.4, 0.0, 0.0);
    glRotatef(-90, 0.0, 0.0, 1.0);
    glScalef(1.0, 1.0, 0.1);
    gllibCone(0.3, 0.4, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0.5,0.5,1.0);
    glTranslatef(-0.2, 0.0, 0.0);
    glScalef(1.0, 1.0, 0.1);
    gllibSphere(0.3, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0.5,0.5,1.0);
    glRotatef(-90, 0.0, 0.0, 1.0);
    glScalef(1.0, 1.0, 0.1);
    gllibCylinder(0.3,0.4, 20);
    glPopMatrix();
}

void VentiladorCamila::grade(){
    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.0, 0.8, 0.3);
    gllibCylinder(0.01, 1.0, 20);
    glPopMatrix();

    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(0.0, 1.38, 0.18);
    glRotatef(-60, 1.0, 0.0, 0.0);
    gllibCylinder(0.01, 0.3, 20);
    glPopMatrix();
}
